<?php
/**
 * Created by PhpStorm.
 * User: CPR065
 * Date: 2016/10/24
 * Time: 10:46
 */

namespace Common\Common;


class Console {
    private static $output = '';
    static function log($data)
    {
        if (is_array($data) || is_object($data))
        {
            $data = json_encode($data);
        }
        $html = " <script>" ;
        $html.= "console.log('{$data}');" ;
        self::$output .= $html;
        echo Console::fetch_output();
        self::$output = '';
    }
    static function fetch_output()
    {
        if (self::$output !== '')
        {
            self::$output .= '</script>';
        }
        return self::$output;
    }
} 